<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="itcast" uri="http://itcast.cn/common/"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>领养管理</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="keywords" content="Modern Responsive web template, Bootstrap Web Templates, Flat Web Templates, Andriod Compatible web template, 
Smartphone Compatible web template, free webdesigns for Nokia, Samsung, LG, SonyErricsson, Motorola web design" />
<script type="application/x-javascript"> addEventListener("load", function() { setTimeout(hideURLbar, 0); }, false); function hideURLbar(){ window.scrollTo(0,1); } </script>
 <!-- Bootstrap Core CSS -->
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/bootstrap.css">
<!-- Custom CSS -->
<link href="${pageContext.request.contextPath}/css/style1.css" rel='stylesheet' type='text/css' />
<link rel="stylesheet" type="text/css" href="http://www.jq22.com/jquery/font-awesome.4.6.0.css"> 
<!-- jQuery -->
<script src="${pageContext.request.contextPath}/js/jquery-1.11.0.js"></script>

<!---//webfonts--->  
<!-- Bootstrap Core JavaScript -->
<script src="${pageContext.request.contextPath}/js/bootstrap.js"></script>
    <script>
    	 /*全选或全不选*/
			//1.页面加载
			$(function(){
				//2.获取下面的复选框并将其选中状态设置跟编码的前端复选框保持一致
				$("#select").click(function(){
					 //atrr方法与JQ的版本有关，在1.8.3以下有关
					//$("tbody input[class='selectOne']").attr("checked",this.checked);
					$("tbody input[class='selectOne']").prop("checked",this.checked);
					
				});
			});
			/*全选删除*/
			function jjj(){
				var pList = "";
	            $("[name='all']").each(function () {
	                if ($(this).is(':checked')) {
	                    pList += $(this).val() + ",";
	                }
	            });
	            //去除最后的，
	           pList=pList.substr(0,pList.length-1);
	           var ids = pList;
	           if(pList==""){
	           	alert("请选择");
	           }else{
	           	var yes = confirm("您确定要删除所选项?");
	           	if(yes){
	           		$.post(
	           		"<%=basePath%>adminAdopt/deleteadopts.html",
	           		{"ids":ids},
	           		function (data) {
						alert("删除成功!");
						location.href="<%=basePath%>adminAdopt/adoptlist.html";
					}
	           		);
	           	}
	           		
	           }

			}
			
		</script>

</head>
<body>
<div id="wrapper">
     <!-- Navigation -->
        <jsp:include page="/WEB-INF/jsp/admin/common.jsp"></jsp:include>
        
        
        <div id="page-wrapper">
           <div class="row" style="background-color: wheat;">
           <div class="col-lg-4"></div>
              <div class="col-lg-8" style="padding-top: 15px;">
               <form class="form-inline" action="${pageContext.request.contextPath }/adminAdopt/adoptlist.html" method="post">
               	      <div class="form-group">
					    <label for="numm">编号:</label>
					    <input type="text" class="form-control" id="numm" name="numm" value="${numm }" placeholder="请输入编号...">
					  </div>
					  <div class="form-group">
					    <label for="ispass">审批:</label>
					    <select id="ispass" name="ispass">
					    	<option value="">--请选择--</option>
					    	<option value="1" <c:if test="${ispass==1 }">selected</c:if>>是</option>
					    	<option value="2" <c:if test="${ispass==2 }">selected</c:if>>否</option>
					    </select>
					  </div>
						  <!-- <div class="form-group">
						    <label for="exampleInputEmail2">日期:</label>
						    <input type="date" class="form-control" id="exampleInputEmail2" placeholder="jane.doe@example.com">
						  </div> -->
					  <button type="submit" class="btn btn-default">搜索</button>
					</form>
              </div>
              
           </div>
           
        <div class="row">
        <div class="col-md-12">  
  	       <h3>领养管理</h3>
  	        <div class="bs-example4" data-example-id="contextual-table">
              <table class="table table-hover">
	             <caption><input type="checkbox" id="select">
	             	<a href="#" class="btn btn-danger btn-sm" onclick="jjj()">
									<span class="glyphicon glyphicon-trash"></span> 批量删除
								</a>
	             </input>
	             </caption>
					<thead>
						<tr>
							<th>序号</th>
							<th>姓名</th>
							<th>图片</th>
							<th>品种</th>
							<th>编号</th>
							<th>送养人</th>
							<th>联系方式</th>
							<th>邮箱</th>
							<th>审批</th>
							<th>操作</th>
							
						</tr>
					</thead>
						<tbody>
						<c:forEach var="row" items="${page.rows }" varStatus="vs">
							<tr>
								<td><input type="checkbox" class="selectOne" value="${row.id }" id="all" name="all"/><span id="sid" style="padding-left: 5px;">${vs.count }</span></td>
								<td>${row.adoptname }</td>
								<td>
									 <img src="${row.adpotimage }" class="img-thumbnail" alt="Cinque Terre" width="30px" height="30px">
								</td>
								
								<c:if test="${row.adoptkind == 1}">
								<td>狗狗</td>
								</c:if>
								
								<c:if test="${row.adoptkind == 2}">
								<td>猫猫</td>
								</c:if>
								
								<c:if test="${row.adoptkind == 3}">
								<td>其他</td>
								</c:if>
								<td>${row.adoptnum }</td>
								<td>${row.adoptman }</td>
								<td>${row.adopttel }</td>
								<td>${row.adoptemail }</td>
								<td>${row.adoptgrant==1?"是":"否" }</td>
								<td>
								<!--编辑-->
								<c:if test="${row.adoptgrant==2 }">
								<a href="#" class="btn btn-info btn-sm" onclick="allow(${row.id})">	
									<span class="glyphicon glyphicon-edit"></span>通过审核		
								</a>
								</c:if>
								&nbsp;&nbsp;
								<c:if test="${row.adoptgrant==1 }">
								<a href="#" class="btn btn-info btn-sm" onclick="cancelAllow(${row.id})">	
									<span class="glyphicon glyphicon-edit"></span>取消		
								</a>
								</c:if>
								&nbsp;&nbsp;
								<!--删除-->							
								<a href="#" class="btn btn-danger btn-sm" onclick="deleteadopt(${row.id})">
									<span class="glyphicon glyphicon-trash"></span> 删除
								</a>
								
							</td>	
							</tr>
							</c:forEach>
					</tbody>
				</table>
				<div class="col-md-12 text-right">
							<span>共<font style="color: red;">${total}</font>条数据</span><itcast:page url="${pageContext.request.contextPath }/adminAdopt/adoptlist.html" />
						</div>
             </div>
            </div>
            </div>
            
            
      </div>
      <!-- /#page-wrapper -->
   </div>		
<!-- Nav CSS -->
<link href="${pageContext.request.contextPath}/css/custom.css" rel="stylesheet">
<!-- Metis Menu Plugin JavaScript -->
<script src="${pageContext.request.contextPath}/js/metisMenu.min.js"></script>
<script src="${pageContext.request.contextPath}/js/custom.js"></script>
<script type="text/javascript">
	function allow(id) {
		var y = confirm("确定通过审核?");
		if(y){
			$.post(
				"<%=basePath%>adminAdopt/allowpass.html",
				{"id":id},
				function (data) {
					alert("已通过!已通知!");
					location.href="<%=basePath%>adminAdopt/adoptlist.html";
				}
			);
		}
	}
	function cancelAllow(id) {
		var y = confirm("取消通过?");
		if(y){
			$.post(
				"<%=basePath%>adminAdopt/cancelPass.html",
				{"id":id},
				function (data) {
					alert("已取消!已通知!");
					location.href="<%=basePath%>adminAdopt/adoptlist.html";
				}
			);
		}
	}
	function deleteadopt(id) {
		var y = confirm("确定删除?");
		if(y){
			$.post(
				"<%=basePath%>adminAdopt/deladopt.html",
				{"id":id},
				function (data) {
					alert("删除成功!");
					location.href="<%=basePath%>adminAdopt/adoptlist.html";
				}
			);
		}
	}
</script>
</body>
</html>